package com.yi.servicepassengeruser.controller;

import com.yi.internalcommon.dto.ResponseResult;
import com.yi.internalcommon.request.VerificationCodeDTO;
import com.yi.servicepassengeruser.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 根据手机号插入用户
     * @param verificationCodeDTO
     * @return
     */
    @PostMapping("/user")
    public ResponseResult loginOrRegister(@RequestBody VerificationCodeDTO verificationCodeDTO){
        String passengerPhone = verificationCodeDTO.getPassengerPhone();
        ResponseResult responceResult = userService.loginOrRegister(passengerPhone);
        return  responceResult;
    }
    /**
     * 根据手机号查询用户信息
     * @param phone
     * @return
     */
    @GetMapping("/user/{phone}")
    public ResponseResult getUser(@PathVariable("phone") String phone){
        ResponseResult responceResult = userService.getUserByPhone(phone);
        return  responceResult;
    }


}
